#ifndef __BASIC_H__
#define __BASIC_H__

#include <my_head.h>
#include "ulink.h"

#define IP_ADDR "192.168.250.100"

#define MSGPATH "/home/linux/myworks/"
#define MAXLINK 10

/* 数据统一结构*/
/*登录数据*/
typedef struct{   
    char ID[128];
    char password[7];
    char flags; //成功 1 失败 0
}user_t;

/*查看环境数据*/
typedef struct{
	unsigned int temp;
	unsigned int hume;
	unsigned int lux;
} env_t;

typedef struct{
	char swlight;//照明开关 1开，0关
	char swfan;//风扇，空调 0关，其他是开
	char swmotor;//加湿器马达 1开，0关
}switch_t;

/*设置阈值数据*/
typedef struct{
	unsigned int tempup;
	unsigned int tempdown;
	unsigned int humeup;
	unsigned int humedown;
	unsigned int luxup;
	unsigned int luxdown;
} limitset_t;

typedef struct{
	long msgtype;
	char commd;
	user_t user;
	env_t envdata;
	switch_t switchset;
	limitset_t limitset;
	/*设备是否在线*/
	char deviceonline;
	/*控制设备数据*/
	char devctrl;
} msg_t;

msg_t msg;

link_t *L;

int msqid;

char ID[128];

//初始化网络
int tcp_net_int(const char *port);

//登录子线程处理的事情
void *login_thread(void *argv);

//服务器子线程处理的事情
void *handl_thread(void *argv);


#endif